<template>
	<div class="wrap">
		<img class="logo" src="../../static/logo_w.png" alt="">
		<button v-if="radius == true" id="btn" open-type="getPhoneNumber"
			@getphonenumber="getPhoneNumber">手机快捷登陆</button>
		<button v-else id="btn" @tap.stop="btn">手机快捷登陆</button>
		<div class="text">
			<div @tap.stop="checked">
				<div class="radius" v-if="radius == false"></div>
				<img class="radius-checked" src="../../static/benefits.png" v-else></img>
			</div>

			<div>
				已阅读并同意
				<span class="orange" @tap.stop='agreement(0)'>用户协议</span>
				和
				<span class="orange" @tap.stop='agreement(1)'>隐私政策</span>
			</div>
		</div>
	</div>
</template>
<script>
	// import cjSlider from '@/components/jxs-slider/jxs-slider.vue'
	import config from '../../config.js';
	export default {
		// components: {
		// 	cjSlider
		// },
		data() {
			return {
				radius: false,
				code: '',

			}
		},
		onLoad(option) {
			let that = this

			uni.login({
				provider: 'weixin',
				success: (loginRes) => {
					that.code = loginRes.code;

				},
				fail: () => {
					uni.showToast({
						icon: 'none',
						title: '小程序登录失败'
					});
				}
			});
		},

		onReady() {

		},

		onShow() {},

		onShareAppMessage(res) { //发送给朋友
			return {
				title: '逸居盛京',
				path: '/pages/home/index',
				imageUrl: "",
			}
		},
		onShareTimeline(res) { //分享到朋友圈
			return {
				title: '逸居盛京',
				path: '/pages/home/index',
				imageUrl: "",
			}
		},
		methods: {
			getPhoneNumber(e) {
				let data = {
					code: this.code,
					encryptedData: e.detail.encryptedData,
					iv: e.detail.iv,
				}

				if (e.detail.encryptedData) {
					this.api.get('system/collect/app/selAppCode', data).then(res => {
						if (res.data.code == 200) {
							uni.setStorageSync('openId', res.data.data.openId)
							// 0用户 1总经理
							uni.setStorageSync('permission', res.data.data.permission)
							uni.setStorageSync('phone', res.data.data.phoneNumber)
							uni.reLaunch({
								url: "/pages/my/my"
							})
						}
					})
				}
			},
			agreement(id) {
				uni.navigateTo({
					url: '/pages/my/agreement?id=' + id
				})
				if (id == 0) {
					// 用户协议

				} else {
					// 隐私政策
				}
			},

			btn() {
				uni.showToast({
					title: '请勾选相关协议',
					icon: 'none',
					duration: 1500,
				});
			},
			checked() {
				this.radius = !this.radius
			}
		}
	}
</script>


<style lang="scss">
	page {
		width: 750rpx;
		height: 100%;
		background-color: #f9f9f9;
		box-sizing: border-box;
	}

	.wrap {
		width: 650rpx;
		height: 100vh;
		margin: 0 auto;

		.logo {
			width: 450rpx;
			height: 180rpx;
			margin: 150rpx 120rpx;
		}

		button::after {
			border: 0;
		}

		#btn {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			color: #ffffff;
			background-color: #f45600;
			text-align: center;
			border-radius: 50rpx;
		}

		.text {
			position: fixed;
			bottom: 100rpx;
			left: 155rpx;
			display: flex;
			height: 30rpx;
			line-height: 30rpx;
			font-size: 26rpx;
			color: #9f9f9f;

			.radius {
				width: 22rpx;
				height: 22rpx;
				border-radius: 50%;
				border: 1rpx solid #adadad;
				// background-color: #ef8545;
				margin-right: 15rpx;
				margin-top: 3rpx;
			}

			.radius-checked {
				width: 22rpx;
				height: 22rpx;
				border-radius: 50%;
				border: 1rpx solid #ef8545;
				// background-color: #ef8545;
				margin-right: 15rpx;
				margin-top: 3rpx;
			}

			.orange {
				color: #ef8545;
				margin: 0 5rpx;
			}
		}
	}
</style>